
GNFORCEINLINE GnCriticalSection::GnCriticalSection()
{
#if defined(GNMULTITHREADED)
#if defined(_DEBUG)
	m_bLocked = false;
#endif  //#if defined(_DEBUG)

	InitializeCriticalSection(&m_kCriticalSection);
#endif // #if !defined(NI_MULTITHREADED)
}

GNFORCEINLINE GnCriticalSection::~GnCriticalSection()
{
#if defined(GNMULTITHREADED)
	DeleteCriticalSection(&m_kCriticalSection);
#endif // #if !defined(NI_MULTITHREADED)
}

GNFORCEINLINE void GnCriticalSection::Lock()
{
#if defined(GNMULTITHREADED)

	EnterCriticalSection(&m_kCriticalSection);
#if defined(_DEBUG)
	GnAssert(m_bLocked == false);
	m_bLocked = true;
#endif  //#if defined(_DEBUG)

#endif // #if !defined(NI_MULTITHREADED)
}

GNFORCEINLINE void GnCriticalSection::Unlock()
{
#if defined(GNMULTITHREADED)

#if defined(_DEBUG)
	m_bLocked = false;
#endif  //#if defined(_DEBUG)

	LeaveCriticalSection(&m_kCriticalSection);
#endif // #if !defined(NI_MULTITHREADED)
}
